const setValues = detailScene => {
  let i = 0;
  let m = 0;
  const dataInput = [];
  const urlPic = [];
  let ContentEdit = "";
  const { sceneTemplateRules = [] } = detailScene;
  if (sceneTemplateRules !== null) {
    sceneTemplateRules.forEach(item => {
      if (item.messageType === 2) {
        urlPic.push({
          key: m,
          value: item.messageParameter,
          messageOrder: item.messageOrder,
          messageUnitName: item.messageUnitName,
          parameterNullContent: item.parameterNullContent,
        });
        m += 1;
      }
      if (item.messageType === 0) {
        ContentEdit += item.messageContent;
      }
      if (
        item.messageType === 1 &&
        item.messageUnitName !== "position" &&
        item.messageUnitName !== "similarity"
      ) {
        ContentEdit += `{${item.messageParameter}}`;
      }
      if (item.messageType === 0 && item.messageContent !== "\n") {
        dataInput.push({
          key: `input${i}`,
          value: item.messageContent, // sceneTemplateId: item.sceneTemplateId,
          messageOrder: item.messageOrder,
          // runtimeEnvironment: item.runtimeEnvironment,
          // templateRuleId: item.templateRuleId,
          parameterNullContent: item.parameterNullContent,
        });
        i += 1;
      }
      if (item.messageType === 0 && item.messageContent === "\n") {
        dataInput.push({
          key: `input${i}`,
          value: "回车", // sceneTemplateId: item.sceneTemplateId,
          messageOrder: item.messageOrder,
          // runtimeEnvironment: item.runtimeEnvironment,
          // templateRuleId: item.templateRuleId,
          parameterNullContent: item.parameterNullContent,
        });
        i += 1;
      }
      if (
        item.messageType === 1 &&
        item.messageUnitName !== "position" &&
        item.messageUnitName !== "similarity"
      ) {
        dataInput.push({
          key: `select${i}`,
          value: item.messageParameter, // sceneTemplateId: item.sceneTemplateId,
          messageOrder: item.messageOrder,
          // runtimeEnvironment: item.runtimeEnvironment,
          // templateRuleId: item.templateRuleId,
          parameterNullContent: item.parameterNullContent,
        });
        i += 1;
      }
    });
  }
  return { dataInput, ContentEdit, i, urlPic };
};

const stateData = {
  manager: [],
  managerName: [],
  scene: "",
  depart: "",
  source: "",
  description: "",
  Content: "",
  Feedback: "",
  ContentEdit: "",
  ContentShow: [],
  noContent: "",
  conVisible: false,
  feedVisible: false,
  editVisible: false,
  showVisible: false,
  sceneNameVisible: false,
  sourceVisible: false,
  depVisible: false,
  urlPic: [{ key: 0, value: "" }],
  ContentEditArr: [],
  ContentArr: [],
  loadingEdit: false,
  sceneTemplateId: "",
  deleteData: [],
  picVisible: false,
  deleteUrl: [],
  selectVisible: false,
  location: {
    messageUnitName: "position",
    messageType: 1,
    messageParameter: "",
  },
  Similarity: {
    messageUnitName: "similarity",
    messageType: 1,
    messageParameter: "",
  },
  editable: true,
  dataInput: [],
  num: 0,
  departmentName: "",
  descripVisible: false,
  feedTextValue: "",
};

export default { setValues, stateData };
